package com.yuwei.message

import android.util.Log
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.tencent.mmkv.MMKV
import com.tencent.smtt.utils.m
import com.yuwei.base.BaseFragment
import com.yuwei.base.path.RouterPath
import com.yuwei.http.Const
import com.yuwei.message.databinding.FragmentMessageBinding


@Route(path = RouterPath.MODULE_MESSAGE_FRAGMENT)
class MessageFragment : BaseFragment<FragmentMessageBinding,MessageViewModel>() {
    val messageAdapter = MessageAdapter()
    override fun initView() {
        viewModel.getMessage(Const.ACCESS_ID,MMKV.defaultMMKV().decodeInt("userId",0))
        binding.messageFragmentRv.adapter = messageAdapter
        binding.messageFragmentRv.layoutManager = LinearLayoutManager(requireContext())
    }

    override fun initData() {
        viewModel.messageSuccess.observe(requireActivity()){
            messageAdapter.data.addAll(it)
            messageAdapter.notifyDataSetChanged()
        }
    }

}